package com.dtease.agent.biz.ai.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dtease.agent.biz.ai.entity.BasPurposeConfig;
import com.dtease.agent.biz.ai.mapper.BasPurposeConfigMapper;
import com.dtease.agent.biz.ai.service.IBasPurposeConfigService;
import com.dtease.agent.biz.ai.vo.BasPurposeConfigVO;
import com.dtease.agent.biz.ai.wrapper.BasPurposeConfigVOWrapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

import static com.dtease.agent.core.constants.BizConstants.Numbers.ZERO_NUM;

/**
 * <p>
 * 用户意图配置表，存储可用的用户意图类型及其基础信息 服务实现类
 * </p>
 *
 * @author chentl
 * @since 2025-05-12
 */
@Service
public class BasPurposeConfigServiceImpl extends ServiceImpl<BasPurposeConfigMapper, BasPurposeConfig> implements IBasPurposeConfigService {

    @Override
    public List<BasPurposeConfigVO> getPurposeList() {
        // 查询可用的大模型列表
        List<BasPurposeConfigVO> purposeConfigVOList = lambdaQuery()
                .eq(BasPurposeConfig::getInvalid, ZERO_NUM)
                .list()
                .stream()
                .map(o -> BasPurposeConfigVOWrapper.build().entityVO(BasPurposeConfigVO.builder()
                        .id(o.getId())
                        .code(o.getCode())
                        .name(o.getName())
                        .ctime(o.getCtime())
                        .mtime(o.getMtime())
                        .open(o.getOpen())
                        .chatMode(o.getChatMode())
                        .build()))
                .collect(Collectors.toList());

        return purposeConfigVOList;
    }
}
